<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <!-- Apple devices fullscreen -->
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <!-- Apple devices fullscreen -->
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <base target="mainFrame" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__css/index.css?2013-9-28-2" media="all" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__css/bootstrap_min.css?2013-9-28-2" media="all" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__css/bootstrap_responsive_min.css?2013-9-28-2" media="all" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__css/style.css?2013-9-28-2" media="all" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__css/themes.css?2013-9-28-2" media="all" />
    <script type="text/javascript" src="__PUBLIC__js/jQuery.js?2013-9-28-2"></script>
    <script type="text/javascript" src="__PUBLIC__js/application.js?2013-9-28-2"></script>
    <script type="text/javascript" src="__PUBLIC__js/bootstrap_min.js?2013-9-28-2"></script>
    <title>天团后台管理</title>
    <!--[if IE 7]>
    <link href="__PUBLIC__css/font_awesome_ie7.css" rel="stylesheet" />
    <![endif]-->
    <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="__PUBLIC__js/excanvas_min.js"></script><![endif]-->
</head>

<body>
<div id="navigation">
    <div class="container-fluid">
        <div>
            <a href="{:U('Admin/Wechat/index')}" target="_self" id="brand">天团后台管理</a>
            <a href="{:U('Admin/Wechat/index')}" target="_self" class="toggle-nav" rel="tooltip" data-placement="bottom" title="Toggle navigation"><i class="icon-reorder"></i></a>
        </div>
        <ul class='main-nav'>
            <?php
            if(count($menus)>0):foreach($menus as $item):
            if($userinfo['username']=='rekeadmin'||$userinfo['username']=='admin'): ?>
            <li class='menu'><a href="javascript:;"><?php echo $item['sys_menu_name']?></a></li>
            <?php else:
            $module=json_decode($type['module']);
            if(count($module)>0):foreach($module as $mod):if($mod->sys_menu_id==$item['sys_menu_id']):
            ?>
            <li class='menu'><a href="javascript:;"><?php echo $item['sys_menu_name']?></a></li>
            <?php endif;endforeach;endif;endif;endforeach;endif;?>
        </ul>

        <div class="user">
            <ul class="icon-nav">
                <li class='dropdown'>
                    <a href="#" class='dropdown-toggle' data-toggle="dropdown" title="消息" style="display:none;"><i class="icon-envelope"></i><span class="label label-lightred">4</span></a>
                </li>
                <li class="dropdown sett" style="display:none;">
                    <a href="#" class='dropdown-toggle' data-toggle="dropdown" title="系统设置"><i class="icon-cog"></i></a>
                </li>
                <li class='dropdown colo'>
                    <a href="#" class='dropdown-toggle' data-toggle="dropdown" title="选择颜色"><i class="icon-tint"></i></a>
                    <ul class="dropdown-menu pull-right theme-colors">
                        <li class="subtitle">选择颜色
                        </li>
                        <li>
                            <span class='red'></span>
                            <span class='orange'></span>
                            <span class='green'></span>
                            <span class="brown"></span>
                            <span class="blue"></span>
                            <span class='lime'></span>
                            <span class="teal"></span>
                            <span class="purple"></span>
                            <span class="pink"></span>
                            <span class="magenta"></span>
                            <span class="grey"></span>
                            <span class="darkblue"></span>
                            <span class="lightred"></span>
                            <span class="lightgrey"></span>
                            <span class="satblue"></span>
                            <span class="satgreen"></span>
                        </li>
                    </ul>
                </li>
                <li class="dropdown">
                    <a href="#" class='dropdown-toggle' data-toggle="dropdown">{$userinfo['usernickname']}</a>
                </li>
                <li class="dropdown" >
                    <a  href="{:U('admin/login/logout')}"  target="_self"  title="退出"><i class="icon-signout"></i> 退出</a>
                </li>
            </ul>
        </div>
    </div>
</div>

<div class="container-fluid" id="content">
    <div id="left">
        <?php if($userinfo['username']=='rekeadmin'||$userinfo['username']=='admin'){?>
        <?php
        if(count($menus)>0):foreach($menus as $item):
        $b=false;
        $ejmenus=M('sys_menu')->where(array('parent_id'=>$item['sys_menu_id']))->order('sort_num asc')->select();
        if(count($ejmenus)>0):foreach($ejmenus as $em):
        $sjmenus=M('sys_menu')->where(array('parent_id'=>$em['sys_menu_id']))->order('sort_num asc')->select();
        if(count($sjmenus)>0):$b=true;endif;
        endforeach;endif;
        ?>
        <?php if(!$b){?>
        <div class="subnav hide">
            <div class="subnav-title ">
                <a href="javascript:void(0)" class='toggle-subnav'><i class="icon-angle-right"></i><span><?php echo $item['sys_menu_name']?></span></a>
            </div>
            <ul class="subnav-menu" style="display: block">
                <?php
                $ejmenus=M('sys_menu')->where(array('parent_id'=>$item['sys_menu_id']))->order('sort_num asc')->select();
                if(count($ejmenus)>0):foreach($ejmenus as $m):
                ?>
                <li>
                    <a href="__ROOT__/<?php echo $m['link_url']?>"><?php echo $m['sys_menu_name']?></a>
                </li>
                <?php endforeach;endif;?>
            </ul>
        </div>
        <?php }else{?>
        <div class="subnav hide">
            <?php
                    $ejmenus=M('sys_menu')->where(array('parent_id'=>$item['sys_menu_id']))->order('sort_num asc')->select();
            if(count($ejmenus)>0):foreach($ejmenus as $em):
            ?>
            <div class="subnav-title ">
                <a href="javascript:void(0)" class='toggle-subnav'><i class="icon-angle-right"></i><span><?php echo $em['sys_menu_name']?></span></a>
            </div>
            <ul class="subnav-menu" style="display: block">
                <?php
                        $sjmenus=M('sys_menu')->where(array('parent_id'=>$em['sys_menu_id']))->order('sort_num asc')->select();
                if(count($sjmenus)>0):foreach($sjmenus as $m):
                ?>
                <li>
                    <a href="__ROOT__/<?php echo $m['link_url']?>"><?php echo $m['sys_menu_name']?></a>
                </li>
                <?php endforeach;endif;?>
            </ul>
            <?php endforeach;endif;?>
        </div>
        <?php }?>
        <?php endforeach;endif;?>
        <?php }else{?>
        <?php
        if(count($menus)>0):foreach($menus as $item):
        $b=false;
        $ejmenus=M('sys_menu')->where(array('parent_id'=>$item['sys_menu_id']))->order('sort_num asc')->select();
        if(count($ejmenus)>0):foreach($ejmenus as $em):
        $sjmenus=M('sys_menu')->where(array('parent_id'=>$em['sys_menu_id']))->order('sort_num asc')->select();
        if(count($sjmenus)>0):$b=true;endif;
        endforeach;endif;
        $module=json_decode($type['module']);
        if(count($module)>0):foreach($module as $mod):if($mod->sys_menu_id==$item['sys_menu_id']):
        ?>
        <?php if(!$b){?>
        <div class="subnav hide">
            <div class="subnav-title ">
                <a href="javascript:void(0)" class='toggle-subnav'><i class="icon-angle-right"></i><span><?php echo $item['sys_menu_name']?></span></a>
            </div>
            <ul class="subnav-menu" style="display: block">
                <?php
                $ejmenus=M('sys_menu')->where(array('parent_id'=>$item['sys_menu_id']))->order('sort_num asc')->select();
                if(count($ejmenus)>0):foreach($ejmenus as $m):foreach($module as $mo):if($mo->sys_menu_id==$m['sys_menu_id']):
                ?>
                <li>
                    <a href="__ROOT__/<?php echo $m['link_url']?>"><?php echo $m['sys_menu_name']?></a>
                </li>
                <?php endif;endforeach;endforeach;endif;?>
            </ul>
        </div>
        <?php }else{?>
        <div class="subnav hide">
            <?php
                    $ejmenus=M('sys_menu')->where(array('parent_id'=>$item['sys_menu_id']))->order('sort_num asc')->select();
            if(count($ejmenus)>0):foreach($ejmenus as $em):
            ?>
            <div class="subnav-title ">
                <a href="javascript:void(0)" class='toggle-subnav'><i class="icon-angle-right"></i><span><?php echo $em['sys_menu_name']?></span></a>
            </div>
            <ul class="subnav-menu" style="display: block">
                <?php
                        $sjmenus=M('sys_menu')->where(array('parent_id'=>$em['sys_menu_id']))->order('sort_num asc')->select();
                if(count($sjmenus)>0):foreach($sjmenus as $m):foreach($module as $mo):if($mo->sys_menu_id==$m['sys_menu_id']):
                ?>
                <li>
                    <a href="__ROOT__/<?php echo $m['link_url']?>"><?php echo $m['sys_menu_name']?></a>
                </li>
                <?php endif;endforeach;endforeach;endif;?>
            </ul>
            <?php endforeach;endif;?>
        </div>
        <?php }?>
        <?php endif;endforeach;endif;endforeach;endif;?>
        <?php }?>
    </div>
    <div class="right">
        <div class="main">
            <iframe frameborder="0" id="mainFrame" name="mainFrame" src="" style="background: url('img/loading.gif') center no-repeat"></iframe>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){

        $(".menu").eq(0).addClass("active");
        $(".subnav").eq(0).removeClass("hide");
        $(".subnav li").eq(0).addClass("active");
        var url=$(".subnav").eq(0).find('.subnav-menu').eq(0).find('li a').attr('href');
        console.log(url);
        $('#mainFrame').attr('src',url);
    });
    P.skn();

//    var url=$(".subnav").eq(0).find('.subnav-menu').eq(0).find('li a').attr('href');
//    $('#mainFrame').attr('src',url);

    var $left_sub = $(".subnav");
    var keyArray = new Array;
    $left_sub.each(function () {
        keyArray.push($(this).attr('data-id'));
    })
    var lfet_select_menu_show = function (index) {
        var $left_a = $("#left a");
        var $a = $left_a.eq(index);
        var $ul = $a.parents(".subnav-menu");
        var $pi = $ul.parent();
        //alert($pi.html());
        var $eq = $.inArray($pi.attr('data-id'), keyArray);
        //alert($eq);
        $(".menu").eq($eq).click();
        $(".subnav").find('.subnav-menu').find('li').removeClass('active');
        $a.parent().addClass('active');
    };

    var curLi;
    $(".menu").click(function(){
        curLi=$(this);
        $(".subnav").hide();
        var i=$(".menu").index(curLi);
        $(".subnav").eq(i).show();
        //alert($(this).html());
        $(".subnav").eq(i).find('.subnav-menu').find('li').removeClass('active');
        $(".subnav").eq(i).find('.subnav-menu').eq(0).find('li').eq(0).addClass('active');
        var url=$(".subnav").eq(i).find('.subnav-menu').eq(0).find('li a').attr('href');
        $('#mainFrame').attr('src',url);
        $('.subnav-menu').show();
    });
</script>
</body>

</html>
